package edu.uc.daoimpl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import edu.uc.bean.Logger;
import edu.uc.dao.LoggerDao;
@Repository("loggerDao")
public class LoggerDaoImpl extends BaseDaoImpl<Logger> implements LoggerDao{

	@Override
	public Long insert(Logger bean) {
		Long  result  =  0L;
	
		try  {
			// 保存
		getTmpl().save(bean);
		
		// 获取主键
		result  =  bean.getId();
		}  catch  (Exception  e)  {
	
			throw  new  RuntimeException(e);
		}  finally  {
	
		}
	
		return  result;
		}

	@Override
	public Long delete(Long id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Long update(Logger bean) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Logger load(Long id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Logger> list() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Long count() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Long countByName(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Logger loadByName(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Logger> pager(Long pageNum, Long pageSize) {
		//  TODO  Auto-generated  method  stub
	
		List<Logger>  vList  =  new  ArrayList<Logger>();
		Long  vStart  =  0L;
		//  Long  vEnd  =  0;
	
		vStart  =  (pageNum  -  1)  *  pageSize;//  下标从0开始,所以不要+1
		//  vEnd  =  pageNum  *  pageSize;
		Long  startIndex  =  vStart;
		StringBuilder  sbHql  =  new  StringBuilder();
		sbHql.append(" from Logger m");
		sbHql.append(" order by m.insertData desc");
		String  hql  =  sbHql.toString();
		List<Object>  arrParams  =  new  ArrayList<Object>();
		Object[]  params  =  arrParams.toArray();
		try  {
			vList  =  getTmpl().execute(this.getCallbackPager(Logger.class,startIndex,pageSize,hql,params));
		} 
		catch  (Exception  e)  {
			throw  new  RuntimeException(e);
		}  
		finally  {
		}
		return  vList;
	}

	@Override
	public List<Logger> pagerByName(String name, Long pageNum, Long pageSize) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Long loggerData(Logger bean) {
		Long  result  =  0L;
		
		try  {
			// 保存
		getTmpl().save(bean);
		
		// 获取主键
		result  =  bean.getId();
		}  catch  (Exception  e)  {
	
			throw  new  RuntimeException(e);
		}  finally  {
	
		}
	
		return  result;
		
	}

}
